if [ ! -f "./tmp.txt" ]; then
    pip3 install -e ".[torch,metrics,deepspeed]"
    pip3 install transformers==4.52.1
    pip3 install vllm==0.7.3 --user
    touch ./tmp.txt
fi
export WANDB_PROJECT=dynamiccot
MODEL_PATH=$1
SOURCE_PATH=$2

llamafactory-cli train \
    --stage sft \
    --do_predict True \
    --model_name_or_path ${MODEL_PATH} \
    --template qwen2_vl \
    --dataset_dir data \
    --eval_dataset mmkp_test \
    --cutoff_len 2048 \
    --max_samples 100000 \
    --preprocessing_num_workers 8 \
    --output_dir ${MODEL_PATH}/predict \
    --overwrite_output_dir true \
    --per_device_eval_batch_size 1 \
    --predict_with_generate true \
    --ddp_timeout 180000000 \
    ${@:3}

python3 scripts/parse_kp.py \
    ${MODEL_PATH}/predict/generated_predictions.jsonl

python3 scripts/kp_pred_evaluate_func.py \
    -pred ${MODEL_PATH}/predict/generated_predictions.txt \
    -src ${SOURCE_PATH}